import React from 'react';
import {Button, Card, Descriptions, Divider, Flex, Space} from "antd";
import {Link, useLocation} from "react-router-dom";
import {SecurityPath} from "../../../type/entity/SecurityPath";
import {BranchesOutlined, CloseOutlined, UpCircleOutlined} from "@ant-design/icons";

const PathDetailsComponent = () => {
    const path = useLocation().state as SecurityPath;

    const delPath = () => {

    };

    const updatePath = () => {

    };

    return (
        <Card title={"请求路径详情信息"} extra={ <Link to={".."}>路径列表</Link> }>
            <Flex style={{margin: "10px 5px"}} justify={"space-between"} gap={50}>
                <Space>
                    <Button type={"primary"} danger icon={<CloseOutlined/>} onClick={delPath}>删除路径</Button>
                    <Button type={"primary"} icon={<UpCircleOutlined/>} onClick={updatePath}>更新路径</Button>
                </Space>
                {/*<Button style={{ backgroundColor: "#00B96B" }} type={"primary"} icon={<BranchesOutlined />} onClick={authorityPath}>路径权限</Button>*/}
            </Flex>
            <Divider/>
            <Descriptions
                bordered
                column={2}
                size={"middle"}
                layout={"horizontal"}
                items={[
                    {label: "路径编号", children: path.id},
                    {label: "父路径编号", children: path.parentId},
                    {label: "唯一标识", children: path.key, span: 2},
                    {label: "路径模式", children: path.pattern, span: 2},
                    {label: "路径描述", children: path.explain, span: 2},
                    {label: "请求方法", children: path.method},
                    {label: "子路径", children: path.last ? "是" : "否"},
                    {label: "创建时间", children: path.createTime.toString()},
                    {label: "更新时间", children: path.updateTime.toString()},
                    {label: "数据排序", children: path.order},
                    {label: "数据版本", children: path.version},
                    {label: "备注信息", children: path.remark, span: 2}
                ]}
            />
        </Card>
    );
};

export default PathDetailsComponent;